91291e
@@ -114,6 +114,11 @@
class AsyncProcess {
       "hbase.client.start.log.errors.counter";
   public static final int DEFAULT_START_LOG_ERRORS_AFTER_COUNT = 9;
 
+  /**
+   * Configuration to decide whether to log details for batch error
+   */
+  public static final String LOG_DETAILS_FOR_BATCH_ERROR = "hbase.client.log.batcherrors.details";
+
   /**
    * The context used to wait for results from one submit call.
    * 1) If AsyncProcess is set to track errors globally, and not per call (for HTable puts),
@@ -222,6 +227,8 @@
class AsyncProcess {
   protected int serverTrackerTimeout;
   protected int timeout;
   protected long primaryCallTimeoutMicroseconds;
+  /** Whether to log details for batch errors */
+  private final boolean logBatchErrorDetails;
   // End configuration settings.
 
   protected static class BatchErrors {
@@ -243,9 +250,12 @@
class AsyncProcess {
       return !throwables.isEmpty();
     }
 
-    private synchronized RetriesExhaustedWithDetailsException makeException() {
-      return new RetriesExhaustedWithDetailsException(
-          new ArrayList<Throwable>(throwables),
+    private synchronized RetriesExhaustedWithDetailsException makeException(boolean logDetails) {
+      if (logDetails) {
+        LOG.error("Exception occurred! Exception details: " + throwables + ";\nActions: "
+            + actions);
+      }
+      return new RetriesExhaustedWithDetailsException(new ArrayList<Throwable>(throwables),
           new ArrayList<Row>(actions), new ArrayList<String>(addresses));
     }
 
@@ -320,6 +330,7 @@
class AsyncProcess {
 
     this.rpcCallerFactory = rpcCaller;
     this.rpcFactory = rpcFactory;
+    this.logBatchErrorDetails = conf.getBoolean(LOG_DETAILS_FOR_BATCH_ERROR, false);
   }
 
   /**
@@ -1688,7 +1699,7 @@
class AsyncProcess {
 
     @Override
     public RetriesExhaustedWithDetailsException getErrors() {
-      return errors.makeException();
+      return errors.makeException(logBatchErrorDetails);
     }
 
     @Override
@@ -1808,7 +1819,7 @@
class AsyncProcess {
     if (failedRows != null) {
       failedRows.addAll(globalErrors.actions);
     }
-    RetriesExhaustedWithDetailsException result = globalErrors.makeException();
+    RetriesExhaustedWithDetailsException result = globalErrors.makeException(logBatchErrorDetails);
     globalErrors.clear();
     return result;
   }
